import java.util.ArrayList;

import algorithm.*;
import structure.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		String grammar= "S->SSA|e;A->C|AAa|e|AB;B->b|bB|A;C->A|c.";
		//"S->AB;A->aA|a;B->bB|e.";//"S->aAb|SA;A->aA|e|S.";//"S->A|a;A->e.";//"S->e|A|ab|AB;A->BB|e|aBb;B->Ab|aB|b.";
		//"S->A;A->e.";//"S->aA;A->B|CDC;B->e|a;C->B|D;D->e|b.";//"S->AS|A;A->a|B;B->b|S|A.";
		//"E->E+T|TxF|(E)|a;T->TxF|(E)|a;F->(E)|a.";
		////"S->aA|bB;A->e|cAd;B->e.";//"S->SSA|e;A->AAa|e|AB;B->b|bB|A.";
		//"E->E+T|T;T->TxF|F;F->(E)|a.";//"S->SSA|e;A->C|AAa|e|AB;B->b|bB|A;C->A|c.";
		grammar g= new grammar(grammar);
		System.out.println("La grammatica data è: ");
		System.out.println(grammar);
		g.printItAll();
		String w= "cabccaabb";
		System.out.println("La word in input è: " + w);

/*
		g= algorithm.chomskyNormalForm(g);
		matrix matrix= new matrix();
		matrix= utility.createRecognitionMatrix(g.getAllProduction(), w, matrix);*/

		if(algorithm.CYK(g, w)){
			System.out.println("La word in input appartiene al linguaggio generato dalla grammatica data in ingresso.");
		}
		else{
			System.out.println("La word in input NON appartiene al linguaggio generato dalla grammatica data in ingresso.");
		}

		/*NonTerminal nt= new NonTerminal(g.getVN());
		for(int i=0; i<30; i++){
			
			System.out.println(nt.getNewTmpNT());
		}*/
		
	}

}
